feat: register terraform compound subcommands in Cobra command tree#2044
feat: register terraform compound subcommands in Cobra command tree#2044
Conversation
Register compound terraform subcommands (state, providers, workspace) as proper
Cobra child commands with dedicated documentation pages and updated screengrabs.
- Add cmd/terraform/{state,providers,workspace}.go with child subcommands
- Add cmd/terraform/utils.go with newTerraformPassthroughSubcommand helper
- Add compound subcommand parsing (parseCompoundSubcommand, processTerraformCompoundSubcommand)
- Add website documentation for all providers/state/workspace subcommands
- Update screengrabs for all CLI commands
- Add blog posts for chdir config isolation and artifactory store fix
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Warning This PR exceeds the recommended limit of 1,000 lines.Large PRs are difficult to review and may be rejected due to their size. Please verify that this PR does not address multiple issues. |
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2044 +/- ##
==========================================
+ Coverage 75.54% 75.63% +0.09%
==========================================
Files 793 793
Lines 73718 73888 +170
==========================================
+ Hits 55692 55887 +195
+ Misses 14530 14514 -16
+ Partials 3496 3487 -9
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…commands Add per-subcommand compat flag definitions for all 15 compound terraform subcommands (state/providers/workspace families), register them with the command registry, add comprehensive tests, and update website docs with detailed "Native Terraform Flags" sections. Compat flags added: - state list: -state, -id - state mv: -lock, -lock-timeout, -ignore-remote-version - state pull: (none) - state push: -force, -lock, -lock-timeout, -ignore-remote-version - state replace-provider: -auto-approve, -lock, -lock-timeout, -ignore-remote-version - state rm: -lock, -lock-timeout, -ignore-remote-version - state show: -state - providers lock: -platform, -fs-mirror, -net-mirror, -enable-plugin-cache - providers mirror: -platform - providers schema: -json - workspace list: (none) - workspace select: -or-create - workspace new: -lock, -lock-timeout, -state - workspace delete: -force, -lock, -lock-timeout - workspace show: (none) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@coderabbitai full review please |
|
🧠 Learnings used✅ Actions performedFull review triggered. |
|
These changes were released in v1.205.1-rc.1. |
what
state,providers,workspace) as proper Cobra child commands"providers lock"parseCompoundSubcommand,processTerraformCompoundSubcommand)why
Terraform compound subcommands registered in Cobra command tree (#2018)
Previously, compound terraform subcommands (
state list,providers lock,workspace select, etc.) were handled entirely by argument parsing inprocessArgsAndFlags. This had several limitations:[command]suffix"providers lock"weren't supportedFix (Part 1 — argument parsing): Added modular helper functions (
parseCompoundSubcommand,parseQuotedCompoundSubcommand,parseSeparateCompoundSubcommand,processTerraformCompoundSubcommand) with configurable subcommand lists forworkspace,state,providers, andwritecommands. Supports both quoted ("providers lock") and separate (providers lock) forms.Fix (Part 2 — Cobra command tree registration): Registered compound subcommands as proper Cobra child commands:
cmd/terraform/state.go—list,mv,pull,push,replace-provider,rm,showas children ofstateCmdcmd/terraform/providers.go—lock,mirror,schemaas children ofprovidersCmdcmd/terraform/workspace.go—list,select,new,delete,showas children ofworkspaceCmdcmd/terraform/utils.go—newTerraformPassthroughSubcommand()helper creates Cobra child commands that delegate to the parent command's execution flowThe legacy compound subcommand parsing in
processArgsAndFlagsis retained as a fallback for the interactive UI path (which bypasses Cobra) and backward compatibility.Files:
internal/exec/cli_utils.go,internal/exec/cli_utils_test.go,cmd/terraform/utils.go,cmd/terraform/state.go,cmd/terraform/providers.go,cmd/terraform/workspace.go,cmd/terraform/subcommands_test.goPer-subcommand compat flags for compound terraform subcommands
Added per-subcommand compat flag definitions for all 15 compound terraform subcommands, registered them with the command registry, and documented them in the website docs.
Compat flags registered per subcommand:
state list-state,-idstate mv-lock,-lock-timeout,-ignore-remote-versionstate pullstate push-force,-lock,-lock-timeout,-ignore-remote-versionstate replace-provider-auto-approve,-lock,-lock-timeout,-ignore-remote-versionstate rm-lock,-lock-timeout,-ignore-remote-versionstate show-stateproviders lock-platform,-fs-mirror,-net-mirror,-enable-plugin-cacheproviders mirror-platformproviders schema-jsonworkspace listworkspace select-or-createworkspace new-lock,-lock-timeout,-stateworkspace delete-force,-lock,-lock-timeoutworkspace showFiles:
cmd/terraform/compat_flags.go,cmd/terraform/state.go,cmd/terraform/providers.go,cmd/terraform/workspace.go,cmd/terraform/subcommands_test.goWebsite documentation for compound subcommands
Added dedicated documentation pages for 15 terraform compound subcommands across 3 command families, each with detailed "Native Terraform Flags" sections documenting all supported terraform flags per subcommand:
providers/—lock,mirror,schemastate/—list,mv,pull,push,replace-provider,rm,showworkspace/—list,select,new,delete,showEach page follows the existing documentation pattern with frontmatter, Intro component, Screengrab, Usage, Examples, Arguments, Flags, Native Terraform Flags, and See Also sections.
Updated screengrabs
Regenerated all CLI command screengrabs to reflect current help text including the new compound subcommand
[command]suffixes.references
terrafrom providers lockCMD in atmos #2018